Let's do a data analysis of Syracuse Potholes based on data from the civic hackathon https://cityofsyracuse.github.io/RoadsChallenge/
We will plot data and display pothole locations on a map!
In [1]:
import folium
import pandas as pd
First we need to find the latitude and longitude of Syracuse, then estimate the appropriate zoom level...
In [2]:
SYR = (43.0481, -76.1474)
map = folium.Map(location=SYR, zoom_start=14)
map
Out[2]:
We get the data from the RoadsChallange github account
In [3]:
data = pd.read_csv('https://cityofsyracuse.github.io/RoadsChallenge/data/potholes.csv')
data.sample(5)
Out[3]:
Now we take the latitude and longitude of each pothole and show them on a map using circle markers
In [5]:
# NOTE: to_dict('records') converts a pandas dataframe back to a list of dict!
SYR = (43.0481, -76.1474)
map = folium.Map(location=SYR, zoom_start=14)
subset = data.sample(500)
for row in subset.to_records():
coords = (row['Longitude'],row['Latitude'])
loc = str(row['strLocation']) + ' ' + str(row['dtTime'])
marker = folium.Circle(location=coords, radius=15, popup=loc,color='#3186cc',fill_color='#3186cc')
map.add_child(marker)
map
Out[5]:
In [ ]: